package pkg.customer;

import javax.servlet.http.*;

import org.apache.struts.action.*;

import HibernateBeans.Invoice;
import retail.bo.CustomerBo;

public class CustomerBillingAction extends Action {
	private CustomerBo customerBo;
	
	public CustomerBo getCustomerBo() {
		return customerBo;
	}

	public void setCustomerBo(CustomerBo customerBo) {
		this.customerBo = customerBo;
	}

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		HttpSession session = request.getSession();
		
		DynaActionForm myform = (DynaActionForm) form;
		double pay= Double.parseDouble(myform.getString("amount"));
		boolean payed=customerBo.payBill((Invoice) session.getAttribute("invoice"), pay);
		if(payed)
			return mapping.findForward("success");
		return mapping.findForward("failed");
	}
}